<?php /* @var $this Controller */ ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="language" content="en" />

        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/styles.css" />

        <title><?php echo CHtml::encode($this->pageTitle); ?></title>

        <?php Yii::app()->bootstrap->register(); ?>
    </head>

    <body>

        <?php
            Yii::import('ext.helpers.EIniHelper'); //ini file helper
            $ini = Yii::getPathOfAlias('ext.helpers') . DIRECTORY_SEPARATOR . 'settings.ini';
            $iniF = EIniHelper::Load($ini)->Get('SMS');

            $smsmenu = array();
            $smsenabled = $iniF['enabled'];
            if ($smsenabled) {
                $smsmenu = array(
                    'label' => t('SMS'),
                    'icon' => 'icon-notes',
                    'visible' => !Yii::app()->user->isGuest,
                    'items' => array(
                        array('label' => t('Send SMS'), 'url' => array('/site/sendsms')),
                        array('label' => t('SMS Status'), 'url' => array('/sms/admin')),
                    ),
                );
            }
            $smsbalance = Yii::app()->mainsms->balance();
            $smslabel = array();
            if (!Yii::app()->user->isGuest && $smsenabled) {
                $smslabel = array(
                    'class' => 'bootstrap.widgets.TbLabel',
                    'type' => ($smsbalance >= 10) ? 'info' : 'warning', // 'success', 'warning', 'important', 'info' or 'inverse'
                    'label' => t('SMS Balance') . ': ' . $smsbalance,
                    'htmlOptions' => array(
                        'class' => 'pull-right',
                    ),
                );
            };
            $this->widget('bootstrap.widgets.TbNavbar', array(
                'items' => array(
                    array(
                        'class' => 'bootstrap.widgets.TbMenu',
                        'items' => array(
                            array('label' => t('Home'), 'url' => array('/site/index'), 'icon' => 'icon-home'),
                            array('label' => t('Manager Tools'), 'url' => '', 'visible' => /* !Yii::app()->user->isGuest */ Yii::app()->user->checkAccess('Manager'), 'icon' => 'icon-wrench',
                                'items' => array(
                                    array('label' => t('Manage Menu'), 'url' => array('/menu'), 'visible' => Yii::app()->user->checkAccess('Menu Manager')),
                                    array('label' => t('Manage User'), 'url' => array('/user'), 'visible' => Yii::app()->user->checkAccess('User Manager')),
                                    array('label' => t('Manage Role'), 'url' => array('/srbac'), 'visible' => Yii::app()->user->checkAccess('Role Manager')),
                                )),
                            array('label' => t('Manage Customer'), 'url' => '', 'visible' => Yii::app()->user->checkAccess('Customer Manager'), 'icon' => 'icon-user',
                                'items' => array(
                                    array('label' => t('Customer Details'), 'url' => array('/customers')),
                                    array('label' => t('Customer Loan'), 'url' => array('/customerloansetting')),
                                //array('label' => t('Customer Loan Payment'), 'url' => array('/customerloanpayment')),
                                )),
                            array('label' => t('Manage Expenses'), 'url' => array('/expenses'), 'visible' => Yii::app()->user->checkAccess('Expenses Manager')),
                            //array('label' => t('Report'), 'url' => array(''), 'visible' => !Yii::app()->user->isGuest),
                            array('label' => t('About'), 'url' => array('/site/page', 'view' => 'about'), 'visible' => Yii::app()->user->isGuest),
                            array('label' => t('Contact Us'), 'url' => array('/site/contact'), 'visible' => Yii::app()->user->isGuest),
                            array('label' => Yii::app()->getModule('user')->t("Register"), 'url' => Yii::app()->getModule('user')->registrationUrl, 'visible' => Yii::app()->user->isGuest),
                            array('label' => Yii::app()->getModule('user')->t("Profile"), 'url' => Yii::app()->getModule('user')->profileUrl, 'visible' => !Yii::app()->user->isGuest, 'icon' => 'icon-file'),
                            array('label' => Yii::app()->getModule('user')->t("Login"), 'url' => Yii::app()->getModule('user')->loginUrl, 'visible' => Yii::app()->user->isGuest),
                            array('label' => Yii::app()->getModule('user')->t("Logout") . ' (' . Yii::app()->user->name . ')', 'url' => Yii::app()->getModule('user')->logoutUrl, 'visible' => !Yii::app()->user->isGuest, 'icon' => 'icon-off'),
                            $smsmenu
                        ),
                    ),
                    $smslabel,
                    array(
                        'class' => 'bootstrap.widgets.TbLabel',
                        'type' => 'important', // 'success', 'warning', 'important', 'info' or 'inverse'
                        'label' => t('Date') . ': ' . date('Y-m-d'),
                        'htmlOptions' => array(
                            'class' => 'pull-right',
                        ),
                    ),
                ),
            ));
        ?>

        <div class="container" id="page">

            <?php if (isset($this->breadcrumbs)): ?>
                    <?php
                    $this->widget('bootstrap.widgets.TbBreadcrumbs', array(
                        'links' => $this->breadcrumbs,
                    ));
                    ?><!-- breadcrumbs -->
                <?php endif ?>

            <?php echo $content; ?>

            <div class="clear"></div>

            <div id="footer" class='span3 offset4 well-large' align='center'>
                Copyright &copy; <?php echo date('Y'); ?> by <?php echo t('Long Finance'); ?>.<br/>
                All Rights Reserved.<br/>
                <?php echo Yii::powered(); ?>
            </div><!-- footer -->

        </div><!-- page -->

    </body>
</html>
